/************************************************
 * Copyright (c) 2007 ~ 2009, 
 * All rights reserved.
 * Version   : 1.0
 * Author    : lengsh@gmail.com 
 * Date      : 2008.1.2
 ***********************************************/

#ifndef _PANDA_HELPER_H______
#define _PANDA_HELPER_H______

#include <string>
#include <map>
#include <iostream>
#include <glib.h>
#include <pthread.h>
#include <string.h>
#include "define.h"
#include "Events.h"
#include "antxdef.h"

using namespace std;

class Helper 
{
	protected:
		static Helper *_instance;
		bool  Startup(const char *filename);

	protected:
		string m_sConfFile;
                volatile unsigned long m_gets;
                volatile unsigned long m_sets;
                Events *m_pEvents;
                int m_update_port;
///////////
	public:

		static Helper *Instance(const char *conf = NULL);
		static void Release( bool bForce = false);
	protected:
		Helper();
		virtual ~Helper();
                int ReBuild(const char *usr, bool remote = false );	
	public:
		int Update(const char *key, int klen, int flags, time_t expire, const char *data, int dlen);
		int Process(map < int, string > &keys, conn *c); 
		int Process(const char *cmd, conn *c); // char **wbuf, int &wsize, int &wbytes);
		int Timer(long time, int gap);
                int Check(void *args);
		char *Stats(char * ext_stats);

		int Get_Relations(char *ua, char *ub, int limit, int offset, conn *c);// char **wbuf, int &wsize, int &wbytes);
		int Get_Friends(char *u, int limit, int offset, conn *c); // char **wbuf, int &wsize, int &wbytes);
		int Get_Type_Friends(char *u, int type, int limit, int offset, conn *c); // char **wbuf, int &wsize, int &wbytes);
		int Get_Infomation(char *user, conn* c); // char **wbuf, int &wsize, int &wbytes);
                bool Clear();

};


#endif 

